<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  <style type="text/css">
    .highlight { display: block; background-color: #ddd; }
  </style>
  <script type="text/javascript">
    function highlight() {
      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
    }
  </script>
</head>
<body onload="prettyPrint(); highlight();">
  <pre class="prettyprint lang-js"><span id='global-property-'>/**
</span> * @ignore
 * justifyCenter button.
 * @author yiminghe@gmail.com
 */
KISSY.add(&quot;editor/plugin/justify-center&quot;, function (S, Editor, justifyCenterCmd) {
    function exec() {
        var editor = this.get(&quot;editor&quot;);
        editor.execCommand(&quot;justifyCenter&quot;);
        editor.focus();
    }

    function justifyCenter() {
    }

    S.augment(justifyCenter, {
        pluginRenderUI:function (editor) {
            justifyCenterCmd.init(editor);
            editor.addButton(&quot;justifyCenter&quot;, {
                tooltip:&quot;居中对齐&quot;,
                checkable:true,
                listeners:{
                    click:exec,
                    afterSyncUI:function () {
                        var self = this;
                        editor.on(&quot;selectionChange&quot;, function () {
                            if (editor.get(&quot;mode&quot;) == Editor.Mode.SOURCE_MODE) {
                                return;
                            }
                            if (editor.queryCommandValue(&quot;justifyCenter&quot;)) {
                                self.set(&quot;checked&quot;, true);
                            } else {
                                self.set(&quot;checked&quot;, false);
                            }
                        });
                    }
                },
                mode:Editor.Mode.WYSIWYG_MODE
            });


            editor.docReady(function () {
                editor.get(&quot;document&quot;).on(&quot;keydown&quot;, function (e) {
                    if (e.ctrlKey &amp;&amp; e.keyCode == S.Node.KeyCode.E) {
                        editor.execCommand(&quot;justifyCenter&quot;);
                        e.preventDefault();
                    }
                });
            });
        }
    });

    return justifyCenter;
}, {
    requires:['editor', './justify-center/cmd']
});</pre>
</body>
</html>
